package org.example.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.time.Duration;

@Component
public class RedisUtils {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    public void set(String key,String value,int seconds){
        stringRedisTemplate.opsForValue().set(key,value, Duration.ofSeconds(seconds));
    }

    public String get(String key){
        return stringRedisTemplate.opsForValue().get(key);
    }

    public Boolean del(String key){
        return stringRedisTemplate.delete(key);
    }
}
